<?php
class malbum extends CI_Model{
	var $album = "album";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_album,$id_submenu,$title_album,$date_album,$enable_album)
	{
		$this->id_album= $id_album;
		$this->id_submenu= $id_submenu;
		$this->title_album= $title_album;
		$this->date_album= $date_album;
		$this->enable_album= $enable_album;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->album, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->album);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_album'=>$this->id_album,
			'id_submenu'=>$this->id_submenu,
			'title_album'=>$this->title_album,
			'date_album'=>$this->date_album,
			'enable_album'=>$this->enable_album
		);
		return $this->db->insert($this->album, $arrayData);
	}
	
	function update($id_album)
	{
		$arrayData = array(
			'id_submenu'=>$this->id_submenu,
			'title_album'=>$this->title_album,
			'date_album'=>$this->date_album,
			'enable_album'=>$this->enable_album
		);
		$this->db->where('id_album', $id_album);
		return $this->db->update($this->album, $arrayData);
	}
        
	function remove($id_album)
	{
		$this->db->where('id_album', $id_album);
		return $this->db->delete($this->album);
	}	
	
	function detail($id_album)
	{
		$this->db->where('id_album', $id_album);
		$query = $this->db->get($this->album);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('title_album',$name);
		$query = $this->db->get($this->album);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getForWeb(){
		$query = $this->db->get($this->album);	
		return $query->result_array();
	}
	
	function getDetForWeb($id_album)
	{
		$this->db->where('id_album', $id_album);
		$query = $this->db->get($this->album);	
		return $query->result_array();
	}
}
?>